package com.example.administrator.uitest.request;

import android.content.Context;

import com.example.administrator.uitest.http.HttpThread;
import com.example.administrator.uitest.intface.DoView;
import com.example.administrator.uitest.intface.GetResult;


/**
 * Created by 朱子育 on 2018/3/9.
 */

public abstract class BaseRequest {
    private HttpThread httpThread;
    private Context context;

    public BaseRequest(Context context) {
        this.context = context;
    }

    public void conn(final DoView doView){

        httpThread=new HttpThread();
        httpThread.setHttpURL(setHttpURL());
        httpThread.setHttpInface(setHttpInface());
        httpThread.setHttpParams(setHttpParams());
        httpThread.setGetResult(new GetResult() {
            @Override
            public void successful(String result) {
                doView.setSuccessfulView(getHttpResult(result));
            }

            @Override
            public void filed(String result) {
                doView.setFiledView(result);
            }
        });
        httpThread.start();
    }

    protected abstract Object getHttpResult(String result);

    protected abstract String setHttpURL();
    protected abstract String setHttpInface();
    protected abstract String setHttpParams();


}
